﻿<%@ Page Title="" Language="C#" MasterPageFile="~/ZFMaster.Master" AutoEventWireup="true"
    CodeBehind="Search.aspx.cs" Inherits="ZF.WS.house.Search" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <script src=" /js/jqPlugins/jquery.json-2.2.min.js" type="text/javascript"></script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="location mb10_">
        您现在的位置：<a href="/"><%=SiteInfo.Instance.SystemConfig.SiteName %></a>>> <a href="<%=this.Request.Url %>">
            房源查询</a>
    </div>
    <style>
        </style>

    <script>
        var param = { area: "",caid:"", pmax: "", pmin: "", tin: "", fan: "", ht: "", pageIndex: 0 };
        $(function() {
            var search = $(".search");
            search.find("dt span").click(function() {
                var dl = $(this.parentNode.parentNode);
                if (!$(this).hasClass("active")) {
                    dl.find("dt span").removeClass("active");
                    $(this).addClass("active");
                    dl.find("dd").hide();
                    dl.find("dd." + $(this).attr("bind")).show();
                    dl.find("dd span").removeClass("active");
                    $(dl.find("dd." + $(this).attr("bind") + " span")[0]).addClass("active");
                    GetList(param);
                }
            });
            search.find("dd span").click(function() {
                $(this.parentNode).find("span").removeClass("active");
                $(this).addClass("active");
                GetList(param);
            });

            $(".searchList tfoot a").click(function() {

                var key = $(this).attr("index");
                var index = param.pageIndex;
                switch (key) {
                    case "--": index = 0; break;
                    case "-": index--; break;
                    case "+": index++; break;
                    case "++": index = 9999999; break;
                }
                param.pageIndex = index;
                GetList(param);
            });
            GetList(param);
        });

        function GetList(obj) {
            var search = $(".search");
            $(search).find("span.active").each(function() {
                var value = $(this).attr("area");
                if (value != null) {
                    param.area = value;
                }
                value = $(this).attr("caid");
                if (value != null) {
                    param.caid = value;
                }
                value = $(this).attr("pmax");
                if (value != null) {
                    param.pmax = value;
                }
                value = $(this).attr("pmin");
                if (value != null) {
                    param.pmin = value;
                }
                value = $(this).attr("tin");
                if (value != null) {
                    param.tin = value;
                }
                value = $(this).attr("fan");
                if (value != null) {
                    param.fan = value;
                }
                value = $(this).attr("ht");
                if (value != null) {
                    param.ht = value;
                }
                value = $(this).attr("dt");
                if (value != null) {
                    param.dt = value;
                }
            });

            var data = "{param:'" + $.toJSON(obj) + "'}";
 
            $.ajax({
                type: "POST",
                data: data,
                contentType: "application/json",
                url: "/WebService.asmx/GetHouseList",
                success: function(msg) {
                    var obj = $.evalJSON(msg);

                    obj = $.evalJSON(obj.d);
                    param.pageIndex = obj.PageIndex;

                    ResetList(obj.Data);
                }
            });


        }
        function ResetList(arr) {
            var template = '<tr><td class="t1"><a href="/house/houseinfo.aspx?hid={0}" target=_blank class="fl_ fc1">{1}</a> <span class="fc2 fl_">[{2}]</span>  ' +
                            '<a  class="fc3" href="/house/houseinfo.aspx?hid={0}"   target=_blank >{3}</a></td>' +
                            '<td class="t2">{4}</td>' +
                            '<td class="t3"> 【{5}】</td>' +
                            '<td class="t4">{6}</td>' +
                            '<td class="t5">{7}</td>' +
                            '<td class="t6">{8}</td>' +
                        '</tr>';
            var html = "";

            $(arr).each(function() {
                
                html += String.format(template, this.HouseId, this.HouseModel, this.HouseType, this.Title,
                (this.Area != "" ? this.City + "(" + this.Area + ")" : this.City), this.DealType, this.Price,
                this.From, this.Date, "D");
            });
            if (arr.length == 0) {
                html = '<tr><td colspan="6">未有匹配房源</td></tr>';
            }
            $(".searchList tbody tr").remove();
            $(".searchList tbody").append(html);
        }
     
    
    </script>

    <script>
        $(function() {
            $(".searchList tbody td").mousemove(function() {
                $(this.parentNode).addClass("move");
            });
            $(".searchList tbody td").mouseout(function() {
                $(this.parentNode).removeClass("move");
            });
        });
 
    </script>

    <div class="ct1 content mt10_">
        <div class="searchContainer" style="width: 100%">
            <div class="search">
                <table class="w100_ table000_">
                    <tr>
                        <td class="l" rowspan="6">
                            快速搜房
                        </td>
                        <td class="t">
                            区&nbsp;&nbsp;&nbsp;&nbsp;域：
                        </td>
                        <td class="c">
                            <div>
                                <dl>
                                    <dt><span area="" class="<%=this.SelArea==null?"active":"" %>">不 限</span>
                                        <% foreach (var area in this.AreaChilds)
                                           { %>
                                        <span area="<%=area.Id%>" class="<%=AreaId==area.Id?"active":"" %>" bind="a<%=area.Id%>"
                                            paid="<%=area.Id%>">
                                            <%=area.Name%></span>
                                        <%}%>
                                    </dt>
                                    <% foreach (var area in this.AreaChilds)
                                       { %>
                                    <%if (area.Childs.Count > 0)
                                      { %>
                         
                                    <dd class="a<%=area.Id%> <%=AreaId==area.Id?"active":"" %> ">
                                        <span caid="" class="<%=AreaId2==-1?"active":"" %>">不 限</span>
                                        <% foreach (var a in area.Childs)
                                           { %>
                                        <span caid="<%=a.Id%> " class="<%=AreaId2==a.Id?"active":"" %>"><%=a.Name%></span>
                                        <%}%>
                                    </dd>
                                    <%} %>
                                    <%}%>
                                </dl>
                            </div>
                        </td>
                    </tr>
                     
                    
                    <tr>
                        <td class="t">
                            房源类型：
                        </td>
                        <td class="c">
                            <div>
                                <dl>
                                    <dt><span class=" <%=(this.SelDealType==0 || this.SelDealType==1 || this.SelDealType==2)?"active":"" %>"
                                        bind="ht1" dt="1,2">出租房(元/月)</span> <span bind="ht2" dt="3" class=" <%=(this.SelDealType==3)?"active":"" %>">
                                            二手房(万元/套)</span> <span bind="ht3" dt="4" class="<%=(this.SelDealType==4)?"active":"" %>">
                                                一手房(万元/套)</span> </dt>
                                    <dd class="ht1  <%=(this.SelDealType==0 || this.SelDealType==1 || this.SelDealType==2)?"active":"" %>">
                                        <span pmax="" pmin="" class="<%=(this.Price==null&&(this.SelDealType>=-1 && this.SelDealType<=2))?"active":"" %>">
                                            不 限</span>
                                        <% foreach (var zf in this.ZFPrice)
                                           {%>
                                        <span pmax="<%=zf[2] %>" pmin="<%=zf[1] %>" class="<%=this.Price==zf[0]?"active":"" %>">
                                            <%=zf[0] %></span>
                                        <%} %>
                                    </dd>
                                    <dd class="ht2 <%=(this.SelDealType==3)?"active":"" %>">
                                        <span pmax="" pmin="" class="<%=this.Price==null&&this.SelDealType==3?"active":"" %>">
                                            不 限</span>
                                        <% foreach (var zf in this.SfPrice)
                                           {%>
                                        <span pmax="<%=zf[2] %>" pmin="<%=zf[1] %>" class="<%=this.Price==zf[0]?"active":"" %>">
                                            <%=zf[0] %></span>
                                        <%} %>
                                    </dd>
                                    <dd class="ht3 <%=(this.SelDealType==4)?"active":"" %>">
                                        <span pmax="" pmin="" class="<%=this.Price==null&&this.SelDealType==4?"active":"" %>">
                                            不 限</span>
                                        <% foreach (var zf in this.SfPrice)
                                           {%>
                                        <span pmax="<%=zf[2] %>" pmin="<%=zf[1] %>" class="<%=this.Price==zf[0]?"active":"" %>">
                                            <%=zf[0] %></span>
                                        <%} %>
                                    </dd>
                                </dl>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="t">
                            物业类型：
                        </td>
                        <td class="c">
                            <div>
                                <dl>
                                    <dd class="active">
                                        <span ht="" class="<%=this.SelHouseType==null?"active":"" %>">不 限</span>
                                        <% foreach (var ht in this.HouseType)
                                           { %>
                                        <span ht="<%=ht.Key%>" class="<%=this.SelHouseType==ht?"active":"" %>">
                                            <%=ht.Text%></span>
                                        <%}%>
                                    </dd>
                                </dl>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="t">
                            房&nbsp;&nbsp;&nbsp;&nbsp;型：
                        </td>
                        <td class="c">
                            <div>
                                <dl>
                                    <dd class="active">
                                        <span fan="" class=" <%=this.Fan==-1?"active":"" %>">不 限</span>
                                        <%for (int i = 1; i <= 5; i++)
                                          {

                                     
                                        %>
                                        <span fan="<%=i%>" class="<%=this.Fan == i ? "active" : ""%>">
                                            <%=i%>房</span>
                                        <%}%>
                                        <span fan="6" class="<%=this.Fan == 6 ? "active" : ""%>">
                                            6房以上</span>
                                    </dd>
                                </dl>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td class="t">
                            厅&nbsp;&nbsp;&nbsp;&nbsp;型：
                        </td>
                        <td class="c">
                            <div>
                                <dl>
                                    <dd class="active">
                                        <span tin="" class=" <%=this.Tin==-1?"active":"" %>">不 限</span>
                                        <%for (int i = 1; i <= 3; i++)
                                          {

                                     
                                        %>
                                        <span tin="<%=i%>" class="<%=this.Tin == i ? "active" : ""%>">
                                            <%=i%>厅</span>
                                        <%}%>
                                         <span tin="4" class="<%=this.Tin == 4 ? "active" : ""%>">
                                            4厅以上</span>
                                    </dd>
                                </dl>
                            </div>
                        </td>
                    </tr>
                </table>
            </div> 
            <div class="fc_"></div>
            <div class="  searchList w100_">
                <table class=" table000_ w100_">
                    <thead>
                        <tr>
                            <th class="t1">
                                房源地址
                            </th>
                            <th class="t2">
                                区域
                            </th>
                            <th class="t3">
                                类型
                            </th>
                            <th class="t4">
                                租金
                            </th>
                            <th class="t5">
                                中介/个人
                            </th>
                            <th class="t6">
                                日期
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                    </tbody>
                    <tfoot>
                        <tr>
                            <td colspan="6">
                                <a href="javascript:" index="--">首 页</a> <a href="javascript:" index="-">上一页</a>
                                <a href="javascript:" index="+">下一页</a> <a href="javascript:" index="++">未 页</a>
                            </td>
                        </tr>
                    </tfoot>
                </table>
            </div>
        </div>
    </div>
</asp:Content>
